﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using CSharpDesign.DAL;
using CSharpDesign.BLL;

namespace CSharpDesign.Admin
{
    public partial class OrderManger : System.Web.UI.Page
    {
        SqlHelper data = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Get_Info();
            }
        }
        /// <summary>
        /// 删除订单行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            SqlHelper mydata = new SqlHelper();

            string ID = gvInfo.DataKeys[e.RowIndex].Values[0].ToString();
            try
            {
                OrderMangerService.Delete_Orderid(ID);
                Label4.Text = "删除成功！";
                gvInfo.EditIndex = -1;
                Get_Info();
            }
            catch
            {
                Label4.Text = "删除失败！";
            }

        }

        private void Get_Info()
        {
            try
            {
                gvInfo.DataSource = GetCodeBy(0);
                gvInfo.DataBind();
            }
            catch
            {

            }

        }
        protected void gvInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvInfo.PageIndex = e.NewPageIndex;
            Get_Info();
        }
        /// <summary>
        /// 鼠标移动变色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            OrderMangerService.Color(e);

        }

        public DataSet GetCodeBy(int iCount)
        {
            SqlHelper date = new SqlHelper();
            string selectedValue = DropDownList1.SelectedValue;
            string strTop = "";
            string sql;
            try
            {
                sql = OrderMangerService.Select_Value(iCount, selectedValue, ref strTop);
                return OrderMangerService.sql_con(sql);
            }
            catch (Exception)
            {
                throw new Exception("查找失败");
            }

        }


        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Get_Info();
        }

    }
}